<template>
  <div class="normalCard">
    <div class="card-header">
      <div class="card-title" :class="{ dot: showDot, pointer: url !== '' }" :style="{ fontSize: fontSize }" @click="goTo(url)">
        <i class="icon"></i>{{ title }}
        <div class="bt">
          <slot name="button"></slot>
        </div>
      </div>
    </div>
    <div v-show="showBody" class="card-body" :style="cardBodyStyle">
      <slot></slot>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { withDefaults } from "vue";
import { useRouter } from "vue-router";

interface Props {
  title?: string; // 标头
  url?: string; // 点击跳转地址
  fontSize?: string; // 标题字体大小
  showBody?: boolean; // 是否显示内容
  showDot?: boolean; // 是否显示小圆点
  cardBodyStyle?: any; // 内容样式
}

withDefaults(defineProps<Props>(), {
  title: "全景概览",
  url: "",
  fontSize: "24px",
  showBody: true,
  showDot: true,
  cardBodyStyle: () => ({})
});

const emit = defineEmits(["clickEvent"]);
const router = useRouter();

const goTo = (url: string) => {
  if (router.currentRoute.value.path !== url && url !== "") {
    router.push(url);
  }
  emit("clickEvent");
};
</script>

<style lang="scss" scoped>
.normalCard {
  width: 100%;
  height: 100%;
  margin-bottom: 20px;
  background: rgb(140 189 255 / 4%);
  backdrop-filter: blur(8px);
  .card-header {
    position: relative;
    height: 40px;
    padding: 0 16px;
    background-image: radial-gradient(circle at 16% 1e2% rgb(22 108 255 / 50%) 0%, rgb(0 77 255 / 1%) 84%),
      linear-gradient(270deg, rgb(0 69 238 / 1%) 0%, rgb(39 115 255 / 30%) 99%);
    &::before {
      position: absolute;
      inset: 0;
      display: inline-block;
      content: "";
      background: url("../assets/images/cardHeader.png") left no-repeat;
      background-size: auto 100%;
    }
    &::after {
      position: absolute;
      top: 0;
      right: 0;
      left: 0;
      display: inline-block;
      height: 2px;
      content: "";
      background-image: linear-gradient(-89deg, rgb(39 115 255 / 35%) 0%, #14b4ff 88%);
    }
    .card-title {
      position: relative;
      z-index: 1;
      display: flex;
      align-items: center;
      justify-content: flex-start;
      height: 100%;
      font-family: YouSheBiaoTiHei;
      font-size: 30px !important;
      color: #ffffff;
      text-shadow: 0 0 4px #0066ff;
      &.pointer {
        cursor: pointer;
      }
      .icon {
        position: relative;
        box-sizing: border-box;
        display: inline-block;
        width: 15px;
        height: 15px;
        margin-right: 15px;
        border: 2px solid #14b4ff;
        &::before {
          position: absolute;
          top: 3px;
          left: 3px;
          display: inline-block;
          width: 5px;
          height: 5px;
          content: "";
          background: #f9b93b;
          box-shadow:
            0 0 8px 1px #0091f8,
            0 0 4px 0 rgb(33 121 195 / 88%);
        }
      }
      .bt {
        display: flex;
        align-items: center;
        justify-content: center;
        margin-right: 20px;
        margin-left: auto;
      }
    }
  }
  .card-body {
    height: calc(100% - 60px);
    padding: 10px;
  }
}
.dot {
  &::after {
    position: absolute;
    top: 8px;
    right: 0;
    display: inline-block;
    width: 12px;
    height: 4px;
    content: "";
    background: url("../assets/images/cardHeaderRight.svg") no-repeat;
  }
}
</style>
